package com.hdax.dmw.order.api;

import com.hdax.dmw.common.utils.Result;
import com.hdax.dmw.common.utils.TokenUtil;
import com.hdax.dmw.order.dtos.OrderListDto;
import com.hdax.dmw.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(path = "/order/p/")
public class OrderApi {

    @Autowired
    private OrderService orderService;

    @PostMapping(path = "/queryorderlist")
    public Result<List<OrderListDto>> queryorderlist(@RequestBody Map<String,Object> params, HttpServletRequest request){
        Long userId = Long.parseLong(TokenUtil.parseToken(request.getHeader("token")).get("id"));
        params.put("userId",userId);
        return orderService.orderList(params);
    }
}
